import { BasicColumn, FormSchema } from '/@/components/Table';
// 表格字段
export const columns: BasicColumn[] = [
  {
    title: '社区名称',
    dataIndex: 'name',
  },
  {
    title: '所属城市',
    dataIndex: 'city',
  },
  {
    title: '状态',
    dataIndex: 'status',
  },
  {
    title: '操作',
    dataIndex: 'action',
    slots: { customRender: 'action' },
    width: 260,
  },
];
// 表单
export const searchFormSchema: FormSchema[] = [
  {
    field: 'name',
    label: '社区名称',
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'city',
    label: '所属城市',
    colProps: { span: 6 },
    component: 'Select',
    componentProps: {
      placeholder: '请选择',
      options: [
        { label: '曼哈顿', value: '曼哈顿' },
        { label: '纽约', value: '纽约' },
      ],
    },
  },
  {
    field: 'status',
    label: '状态',
    component: 'Select',
    componentProps: {
      placeholder: '请选择',
      options: [
        { label: '已上线', value: '已上线' },
        { label: '已下线', value: '已下线' },
      ],
    },
    colProps: { span: 6 },
  },
];

// 表格数据
export const dataSource = [
  {
    id: 1,
    name: 'LIC',
    city: '大纽约地区',
    status: '已上线',
    seoTitle: 'seo标题',
    seoDesc: 'seo描述',
    seoKeyWord: 'seo关键字',
    seoUrl: 'seo-URL',
    pic: 'pic-URL',
    remark: '简介',
  },
  {
    id: 2,
    name: 'manhatton downtown',
    city: '大纽约地区',
    status: '已下线',
    seoTitle: 'seo标题',
    seoDesc: 'seo描述',
    seoKeyWord: 'seo关键字',
    seoUrl: 'seo-URL',
    pic: 'pic-URL',
    remark: '简介',
  },
];

export const getAccountList = () => {
  return dataSource;
};

export const buildingFormSchema: FormSchema[] = [
  {
    field: 'city',
    label: '所属城市',
    colProps: { span: 12 },
    component: 'Select',
    componentProps: {
      placeholder: '请选择',
      options: [
        { label: '曼哈顿', value: '曼哈顿' },
        { label: '纽约', value: '纽约' },
      ],
    },
    dynamicRules: () => {
      return [
        {
          required: true,
          message: '请输入城市',
        },
      ];
    },
  },
  {
    field: 'name',
    label: '社区名称',
    component: 'Input',
    componentProps: {
      placeholder: '输入中英文名称，用逗号隔开',
    },
    dynamicRules: () => {
      return [
        {
          required: true,
          message: '请输入社区名称',
        },
      ];
    },
  },
  {
    label: '背景图',
    field: 'coverUrl',
    component: 'Upload',
    slot: 'coverUrlSlot',
    rules: [
      {
        required: true,
        validator: async (_rule, value) => {
          if (!value) {
            /* eslint-disable-next-line */
            return Promise.reject('请添加背景图');
          }
          return Promise.resolve();
        },
        trigger: 'change',
      },
    ],
  },
  {
    field: 'areaSpec',
    label: '区域特色',
    component: 'Input',
    slot: 'areaSpecSlot',
    dynamicRules: () => {
      return [
        {
          required: true,
          message: '请输入区域特色',
        },
      ];
    },
  },
  // {
  //   label: '',
  //   field: '',
  //   component: 'Input',
  //   slot: 'buttonSlot',
  // },
  {
    label: '社区简介',
    field: 'remark',
    component: 'InputTextArea',
    componentProps: {
      rows: 4,
      placeholder: '请输入',
    },
    dynamicRules: () => {
      return [
        {
          required: true,
          message: '请输入社区简介',
        },
      ];
    },
  },
  {
    field: 'seoTitle',
    label: 'SEO标题',
    component: 'Input',
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'seoDesc',
    label: 'SEO描述',
    component: 'Input',
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'seoKeyWord',
    label: 'SEO关键字',
    component: 'Input',
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'seoUrl',
    label: 'SEO-URL',
    component: 'Input',
    componentProps: {
      placeholder: '请输入',
    },
  },
  {
    field: 'pic',
    label: '图片ALT',
    component: 'Input',
    componentProps: {
      placeholder: '请输入',
    },
  },
];
